home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / ugly / expstr.h < prev    next >
C/C++ Source or Header  |  1996-10-29  |  3KB  |  101 lines

  1. #ifndef UGLY_EXPSTR_H
  2. #define UGLY_EXPSTR_H
  3.  
  4. /*
  5.  * ugly/expstr.h
  6.  *
  7.  * self-expanding string functions, header
  8.  *
  9.  * (W) by Tommy-Saftwörx in 1995
  10.  *
  11.  */
  12.  
  13. #include <stddef.h>
  14.  
  15. #include "utypes.h"
  16.  
  17. #define EXPSTR_MEMSTEP 96
  18. #define ES_MIN_MEMSTEP 8        /* min. memory step for init( step_size ) */
  19.  
  20. #ifndef modadj
  21. #define modadj(x,by) ((by)*(((x)+(by))/(by)))
  22. #endif
  23.  
  24. /* some inline macros used without DEBUG defined */
  25. #define ugly_inline_estr2str(es) ((es)->es_data)
  26. #define ugly_inline_estrlen(es)  ((es)->es_len - 1)
  27.  
  28. typedef struct
  29. {
  30.     STRPTR es_data;             /* ptr to string data */
  31.     size_t es_len;              /* current len */
  32.     size_t es_size;             /* current size of mem allocated */
  33.     size_t es_step;             /* size of memory step */
  34. }
  35. EXPSTR;
  36.  
  37. /*
  38.  * external prototypes
  39.  */
  40.  
  41. #ifndef NOEXTERN_UGLY_EXPSTR_H
  42.  
  43. extern EXPSTR *ugly_dbg_init_estr(size_t step_size, STRPTR file, ULONG line);
  44. extern EXPSTR *ugly_init_estr(size_t step_size);
  45. extern void del_estr(EXPSTR * es);
  46.  
  47. extern BOOL ugly_clr_estr(EXPSTR * es);
  48. extern BOOL ugly_dbg_clr_estr(EXPSTR * es, STRPTR file, ULONG line);
  49. extern BOOL set_estrn(EXPSTR * es, CONSTRPTR s, size_t n);
  50.  
  51. extern BOOL ugly_set_estr(EXPSTR * es, CONSTRPTR s);
  52. extern BOOL ugly_app_estrch(EXPSTR * es, int ch);
  53. extern BOOL ugly_app_estr(EXPSTR * es, CONSTRPTR s);
  54.  
  55. extern BOOL ugly_dbg_set_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line);
  56. extern BOOL ugly_dbg_app_estrch(EXPSTR * es, int ch, STRPTR file, ULONG line);
  57. extern BOOL ugly_dbg_app_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line);
  58. extern STRPTR ugly_estr2str(EXPSTR * es);
  59. extern size_t ugly_estrlen(EXPSTR * es);
  60.  
  61. extern BOOL estrcpy(EXPSTR * dest, EXPSTR * src);
  62. extern BOOL estrcat(EXPSTR * dest, EXPSTR * src);
  63.  
  64. extern BOOL get_mid_estr(EXPSTR * dest, EXPSTR * src, size_t from, size_t num);
  65. extern BOOL get_right_estr(EXPSTR * dest, EXPSTR * src, size_t num);
  66. extern BOOL get_left_estr(EXPSTR * dest, EXPSTR * src, size_t num);
  67.  
  68. #endif /* NOEXTERN_UGLY_EXPSTR_H */
  69.  
  70. /*
  71.  * debugging prototypes
  72.  */
  73. #if DEBUG_UGLY_EXPSTR
  74.  
  75. /* full debugging */
  76. #define set_estr_mem( es, size ) ugly_dbg_set_estr_mem( es, size, __FILE__, __LINE__ )
  77. #define set_estr( es, s ) ugly_dbg_set_estr( es, s, __FILE__, __LINE__ )
  78. #define app_estrch( es, ch ) ugly_dbg_app_estrch( es, ch, __FILE__, __LINE__ )
  79. #define app_estr( es, s ) ugly_dbg_app_estr( es, s, __FILE__, __LINE__ )
  80. #define init_estr( s ) ugly_dbg_init_estr( s, __FILE__, __LINE__ )
  81. #define clr_estr( s ) ugly_dbg_clr_estr( s, __FILE__, __LINE__ )
  82. #define estr2str( s ) ugly_estr2str( s )
  83. #define estrlen( s ) ugly_estrlen( s )
  84.  
  85. #else
  86.  
  87. /* no debugging */
  88. #define set_estr_mem( es, size ) ugly_set_estr_mem( es, size )
  89. #define set_estr( es, s ) ugly_set_estr( es, s )
  90. #define app_estrch( es, ch ) ugly_app_estrch( es, ch )
  91. #define app_estr( es, s ) ugly_app_estr( es, s )
  92. #define init_estr( s ) ugly_init_estr( s )
  93. #define clr_estr( s ) ugly_clr_estr( s )
  94. #define estr2str( s ) ugly_inline_estr2str( s )
  95. #define estrlen( s ) ugly_inline_estrlen( s )
  96.  
  97. #endif
  98.  
  99. #endif /* UGLY_EXPSTR_H */
  100.  
  101.